<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/Public/css/bootstrap.min.css">
    <link rel="stylesheet" href="/Public/em-ui/index.css">
</head>
<STYLE>
    body {
        width: 740px;
        margin: auto;
    }

    .kong1 {
        height: 20px;
    }
    .imgsid{
        width: 25px;
        height: 25px;
    }
</STYLE>
<body>

<div id="app">
    
    <div class="nva">
        <ul class="el-menu el-menu--horizontal el-menu--dark">
            <a href="<?php echo U('/Admin/main');?>"><li class="el-menu-item">主页</li></a>
            <li class="dropdown el-menu-item"><a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                                    aria-expanded="false"><span class="creat-font" style=" color: white;display: inline-block;height: 70px;line-height: 70px;padding: 0">商品管理</span> <span
                    class="caret"></span></a>
                <ul class="dropdown-menu" id="new"  style="width: 300px">
                    <li><a data-toggle="modal" data-target="#d1" class="font"><span>添加普通商品</span></a></li>
                    <li role="separator" class="divider"></li>
                    <li><a data-toggle="modal" data-target="#d2" class="font"><span>添加特价商品</span></a></li>
                    <li role="separator" class="divider"></li>
                    <li><a data-toggle="modal" data-target="#b4" class="font"><span>添加商品类型</span></a></li>
                </ul>
            </li>
            <!--<a href="<?php echo U('/Admin/main');?>"><li class="el-menu-item">客户管理</li></a>-->
            <a href="<?php echo U('/Admin/Emtpy/index');?>"><li class="el-menu-item">退出登录</li></a>
        </ul>
    </div>


    <div class="kong1"></div>
    <div class="panel panel-primary">
        <div class="panel-heading">
            所有商品<!-- 头部-->
        </div>
        
    <table class="table">
        <tr>
            <th>商品名字</th>
            <th>商品图片</th>
            <th>价格</th>
            <th>折扣</th>
            <th>数量</th>
            <th>类型</th>
            <th>&nbsp;</th>
        </tr>
        <?php if(is_array($shop)): foreach($shop as $key=>$shops): ?><tr>
                <td><?php echo ($shops["shopname"]); ?></td>
                <td><img class="imgsid" src="/Public/imgs<?php echo ($shops["shopimg"]); ?>" alt=""></td>
                <td><?php echo ($shops["price"]); ?></td>
                <?php if($shops["discount"] == 1): ?><td><?php echo ($shops["discount"]); ?></td>
                    <td><?php echo ($shops["number"]); ?></td>
                    <td><?php echo ($shops["leibiename"]); ?></td>
                    <td>&nbsp;</td>
                    <td><a href="<?php echo U('/Admin/Record');?>?id=<?php echo ($shops["idit"]); ?>">删除商品</a></td>
                <?php else: ?>
                    <td><?php echo ($shops["discount"]); ?></td>
                    <td><?php echo ($shops["number"]); ?></td>
                    <td><?php echo ($shops["leibiename"]); ?></td>
                    <td><a data-toggle="modal" data-target="#A<?php echo ($shops["idit"]); ?>" class="font">修改折扣</a></td>
                    <td><a href="<?php echo U('/Admin/Record');?>?id=<?php echo ($shops["idit"]); ?>">删除商品</a></td><?php endif; ?>
            </tr><?php endforeach; endif; ?>
    </table>
<!--身体 -->
    </div>
    
    <div class="modal" id="d1">
        <div class="modal-dialog" style="width:420px;">
            <div class="modal-content">
                <div class="modal-header">
                    <h4>添加普通商品</h4>
                </div>
                <form action="/Admin/Shop/update" method="post" class="form-horizontal" enctype="multipart/form-data">
                    商品：<input type="text" name="shopname"><br><br>
                    图片：<input type="file" name="shopimg"><br><br>
                    价格：<input type="text" name="price"><br><br>
                    数量：<input type="text" name="number"><br><br>
                    类型：<select name="id" id="types">
                        <?php if(is_array($types)): foreach($types as $key=>$type): ?><option id="<?php echo ($type["idty"]); ?>" value="<?php echo ($type["idty"]); ?>"><?php echo ($type["leibiename"]); ?></option><?php endforeach; endif; ?>
                        </select>
                    <div class="modal-footer">
                        <button class="btn btn-primary" type="submit">确定</button>
                        <a class="btn btn-default" data-dismiss="modal">取消</a>
                    </div>
                </form>
            </div>
        </div>
        <!--第二中-->
    </div>
<!--弹窗-->
    
    <div class="modal" id="d2">
        <div class="modal-dialog" style="width:420px;">
            <div class="modal-content">
                <div class="modal-header">
                    <h4>添加折扣商品</h4>
                </div>
                <form action="/Admin/Shop/teijia" method="post" class="form-horizontal" enctype="multipart/form-data">
                    商品：<input type="text" name="shopname"><br><br>
                    图片：<input type="file" name="shopimg"><br><br>
                    价格：<input type="text" name="price"><br><br>
                    数量：<input type="text" name="number"><br><br>
                    折扣：<input type="text" name="discount"><br><br>
                    类型：<select name="ids" id="typ">
                        <?php if(is_array($types)): foreach($types as $key=>$type): ?><option value="<?php echo ($type["idty"]); ?>"><?php echo ($type["leibiename"]); ?></option><?php endforeach; endif; ?>
                        </select>
                    <div class="modal-footer">
                        <button class="btn btn-primary" type="submit">确定</button>
                        <a class="btn btn-default" data-dismiss="modal">取消</a>
                    </div>
                </form>
            </div>
        </div>
        <!--第二中-->
    </div>
<!--弹窗-->
    
    <?php if(is_array($shop)): foreach($shop as $key=>$shops): ?><div class="modal" id="A<?php echo ($shops["idit"]); ?>">
            <div class="modal-dialog" style="width:420px;">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4>修改折扣</h4>
                    </div>
                    <form action="/Admin/Shop/xiugai" method="post" class="form-horizontal">
                        <input type="hidden" value="<?php echo ($shops["idit"]); ?>" name="id">
                        修改折扣：<input type="text" name="name"><br><br>
                        <div class="modal-footer">
                            <button class="btn btn-primary" type="submit">确定</button>
                            <a class="btn btn-default" data-dismiss="modal">取消</a>
                        </div>
                    </form>
                </div>
            </div>
            <!--第二中-->
        </div><?php endforeach; endif; ?>
<!--弹窗-->
    
        <div class="modal" id="b4">
            <div class="modal-dialog" style="width:420px;">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4>添加类型</h4>
                    </div>
                    <form action="/Admin/Shop/csx" method="post" class="form-horizontal">
                        新类型：<input type="text" name="name"><br><br>
                        <div class="modal-footer">
                            <button class="btn btn-primary" type="submit">确定</button>
                            <a class="btn btn-default" data-dismiss="modal">取消</a>
                        </div>
                    </form>
                </div>
            </div>
            <!--第二中-->
        </div>
<!--弹窗-->

</div>

<script src="/Public/js/vue.min.js"></script>
<script src="/Public/js/vue-resource.min.js"></script>
<script src="/Public/em-ui/index.js"></script>
<script src="/Public/js/jquery-1.11.1.min.js"></script>
<script src="/Public/js/bootstrap.min.js"></script>
<script>
    Vue.http.options.emulateJSON = true;

</script>

    <script>
        new Vue({
            el: "#app"
        })
    </script>

</body>
</html>